/* QtLua -- Lua bindings for Qt
   Copyright (C) 2011, Jarek Pelczar

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA

*/

#include "qluascriptengineagent_p.h"
#include "qluascriptengine.h"
#include <QDebug>

QLuaScriptEngineAgentPrivate::QLuaScriptEngineAgentPrivate(QLuaScriptEngine * parent)
    : QObject(parent)
{
    m_engine = parent;
}

QLuaScriptEngineAgentPrivate::~QLuaScriptEngineAgentPrivate()
{
    if(m_agent) {
        m_agent->d = NULL;
        delete m_agent;
        m_agent = NULL;
    }
}

QLuaScriptEngineAgent::QLuaScriptEngineAgent(QLuaScriptEngine * engine)
    : d(new QLuaScriptEngineAgentPrivate(engine))
{
    d->m_agent = this;
}

QLuaScriptEngineAgent::~QLuaScriptEngineAgent()
{
    if(d) {
        d->m_agent = NULL;
        delete d;
    }
}

void QLuaScriptEngineAgent::contextPop()
{

}

void QLuaScriptEngineAgent::contextPush()
{

}

QLuaScriptEngine * QLuaScriptEngineAgent::engine() const
{
    return d ? d->m_engine : NULL;
}

void QLuaScriptEngineAgent::exceptionCatch(qint64 scriptId, const QLuaScriptValue& exception)
{
#ifdef QT_DEBUG
    qDebug() << "[QLuaScriptEngineAgent] Exception catch";
#endif
}

void QLuaScriptEngineAgent::exceptionThrow(qint64 scriptId, const QLuaScriptValue& exception, bool hasHandler)
{
#ifdef QT_DEBUG
    qDebug() << "[QLuaScriptEngineAgent] Exception throw";
#endif
}

QVariant QLuaScriptEngineAgent::extension(Extension extension, const QVariant & argument)
{
    return QVariant();
}

void QLuaScriptEngineAgent::functionEntry(qint64 scriptId)
{

}

void QLuaScriptEngineAgent::functionExit(qint64 scriptId, const QLuaScriptValue & returnValue)
{

}

void QLuaScriptEngineAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
{
#ifdef QT_DEBUG
    qDebug() << "[QLuaScriptEngineAgent] Position change" << scriptId << "Line =" << lineNumber << "Column =" << columnNumber;
#endif
}

void QLuaScriptEngineAgent::scriptLoad(qint64 id, const QString & program, const QString& fileName, int baseLineNumber)
{
#ifdef QT_DEBUG
    qDebug() << "[QLuaScriptEngineAgent] Script load" << id;
#endif
}

void QLuaScriptEngineAgent::scriptUnload(qint64 id)
{
#ifdef QT_DEBUG
    qDebug() << "[QLuaScriptEngineAgent] Script unload" << id;
#endif
}

bool QLuaScriptEngineAgent::supportsExtension(Extension extension ) const
{
    return false;
}
